package tech.summerly.weather.component.adapter.floors

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import kotlinx.android.synthetic.main.floor_life_style.view.*
import tech.summerly.weather.R
import tech.summerly.weather.component.adapter.LifeStyleAdapter
import tech.summerly.weather.data.bean.DailyForecast
import tech.summerly.weather.util.ViewHolder

class LifeStyleFloor : BaseFloor<LifeStyle>() {

    override fun onCreateViewHolder(inflater: LayoutInflater, parent: ViewGroup): ViewHolder {
        val inflated = inflater.inflate(R.layout.floor_life_style, parent, false)
        return LifeStyleFloorHolder(inflated)
    }

    override fun onBindViewHolder(holder: ViewHolder, item: LifeStyle) {
        (holder as LifeStyleFloorHolder).setData(item.forecast)
    }
}

class LifeStyleFloorHolder(itemView: View) : ViewHolder(itemView) {

    private val adapter = LifeStyleAdapter()

    init {
        itemView.listLifeStyle.adapter = adapter
    }

    fun setData(forecast: DailyForecast) {
        adapter.setData(forecast)
    }
}

class LifeStyle(val forecast: DailyForecast)